<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <jsp:include page="../../head.jsp"/>
    <title>Title</title>
    <link href="../../css/jw/jw.css" rel="stylesheet" type="text/css"/>
    <script type="application/javascript" src="../../js/jw/jw.js"></script>
    <script type="application/javascript" src="../../js/gtimp3/declaration.js"></script>
    <script type="text/javascript">
        var formSetting = {
            title: "查询信息",
            module: 'query',
            columns: [
                {
                    name: "company_co",
                    label: "收发货人",
                    type: "dropdown",
                    dropdownType: "ajax",
                    url: "../order-dropdown/company",
                    op: "eq",
                    minLength: 1,
                    keyWordName: "key",
                    success: function (data) {
                        data = data.results;
                        var array = new Array();
                        $.each(data, function (i, n) {
                            array.push([n["text"], n["value"]]);
                        });
                        return array;
                    }
                }, {
                    name: "state",
                    label: "查验状态",
                    type: "dropdown",
                    data: [["查验中", "0"], ["查验完成", "1"], ["查验不通过", "2"], ["海关放行", "14"],
                        ["商检放行", "15"], ["其他放行", "16"]],
                    op: "eq",
                    minLength: 0,
                    value: 0,
                    dropdownValue: "查验中"
                },
                {
                    name: "sno",
                    label: "报关单号"
                }, {
                    name: "begTime",
                    label: "查验日期起",
                    type: "date",
                    op: "ge"
                }, {
                    name: "endTime",
                    label: "查验日期止",
                    type: "date",
                    op: "le"
                }, {
                    name: "businessId",
                    label: "业务编号"
                }],
            buttons: {
                custom: [/*{
                 id: "id4",
                 value: "海关放行",
                 click: function () {
                 var id = $("#inspectionDataGrid").jqGrid("getGridParam", "selrow");
                 if (id) {
                 var ret = $("#inspectionDataGrid").jqGrid('getRowData', id);
                 doDeclarationOk(ret["declaration.id"], '海关放行');
                 } else {
                 alert("请选择需要操作的记录！");
                 }
                 }
                 }, {
                 id: "id5",
                 value: "商检放行",
                 click: function () {
                 var id = $("#inspectionDataGrid").jqGrid("getGridParam", "selrow");
                 if (id) {
                 var ret = $("#inspectionDataGrid").jqGrid('getRowData', id);
                 doDeclarationOk(ret["declaration.id"], '商检放行');
                 } else {
                 alert("请选择需要操作的记录！");
                 }
                 }
                 }，*/
//                    {
//                        id: "id6",
//                        value: "一键放行",
//                        click: function () {
//                            var id = $("#inspectionDataGrid").jqGrid("getGridParam", "selrow");
//                            if (id) {
//                                var ret = $("#inspectionDataGrid").jqGrid('getRowData', id);
//                                doDeclarationOk(ret["declaration.id"], '一键放行');
//                            } else {
//                                alert("请选择需要操作的记录！");
//                            }
//                        }
//                    }
                ]
            },
            grid: {
                id: "inspectionDataGrid",
                title: "查询结果",
                url: "findInspectionGoodsList",
                multiselect: true,
                colModel: [{
                    //index: "ID",
                    //name: "id",
                    name: "trackId",
                    hidden: true
                }, {
                    name: "declaId",
                    hidden: true
                }, {
                    name: "CREATETIME",
                    label: "查验时间"
                }, {
                    name: "containerNo",
                    label: "查验柜号"
                }, {
                    name: "businessId",
                    label: "业务编号"
                }, {
                    name: "sno",
                    label: "报关单号"
                }, {
                    name: "goodsName",
                    label: "货物名称"
                }, {
                    name: "goodsMode",
                    label: "规格型号"
                }, {
                    name: "trueUser",
                    label: "实际托运人"
                }, {
                    name: "compName",
                    label: "收发货人"
                }, {
                    name: "inspectionCompanyProject",
                    label: "实施查验单位&查验项目",
                    width: "400"
                }, {
                    name: "declaType",
                    label: "业务类型",
                    width: "60",
                    formatter: function (cellvalue, options, rowObject) {
                        switch (cellvalue) {
                            case "E":
                                return "出口";
                            case "I":
                                return "进口";
                            default:
                                return "";
                        }
                    }
                }, {
                    name: "bizStatus",
                    label: "查验完成情况",
                    formatter: function (cellvalue, options, rowObject) {
                        switch (cellvalue) {
                            case "0":
                                return "查验中";
                            case "1":
                                return "查验完成";
                            case "2":
                                return "查验不通过";
                            case "4":
                                var dpt = rowObject.inspectionCompanyProject.substring(0, 2);
                                return dpt + "放行";
                        }
                    }
                }/*, {
                 name: "declaration.state",
                 label: "放行情况",
                 formatter: function (cellvalue, options, rowObject) {
                 switch (cellvalue) {
                 /!*case "DS10":
                 return "海关已放行/商检未放行";
                 case "DS11":
                 return "海关未放行/商检已放行";
                 case "DS05":
                 return "海关已放行/商检已放行";*!/
                 default:
                 return "-";
                 }
                 }
                 }*/, {
                    label: "操作",
                    sortable: false,
                    buttons: [{
                        key: "id1",
                        value: "详情",
                        click: function (gridid, rowId, rowdata) {
                            doEdit(rowdata["declaId"], rowdata.declaration_type);
                        }
                    }, {
                        key: "id2",
                        value: "更新记录",
                        hide: function (rowdata) {
                            var comType = '${comType}';
                            return (!comType || (comType != "CC" && comType != "CM"));
                        },
                        click: function (gridid, rowId, rowdata) {
                            inspectionUpdatePage(rowdata["declaId"], rowdata.trackId);
                        }
                    }, {
                        key: "id3",
                        value: "查看记录",
                        hide: function (rowdata) {
                            var comType = '${comType}';
                            return (comType && (comType == "CC" || comType == "CM" ));
                        },
                        click: function (gridid, rowId, rowdata) {
                            inspectionViewPage(rowdata["declaId"], rowdata.trackId);
                        }
                    }/*, {
                     key: "id4",
                     value: "海关放行",
                     hide: function (rowdata) {
                     return (rowdata.state === "DS05" || rowdata.state === "DS10");
                     },
                     click: function (gridid, rowId, rowdata) {
                     doDeclarationOk(rowId, '海关放行');
                     }
                     }, {
                     key: "id5",
                     value: "商检放行",
                     hide: function (rowdata) {
                     return (rowdata.state === "DS05" || rowdata.state === "DS11");
                     },
                     click: function (gridid, rowId, rowdata) {
                     doDeclarationOk(rowId, '商检放行');
                     }
                     }*/],
                    formatter: $.jqGrid.custom.formatter.button
                }],
                sortname: "createTime",
                sortorder: "desc",
                ondblClickRow: function (rowid, iRow, iCol, e) {
                    if (rowid) {
                        var rowData = $("#inspectionDataGrid").jqGrid("getRowData", rowid);
                        doEdit(rowData["declaId"], rowData.declaration_type);
                    }
                }
            }
        };
        $(document).ready(function () {
            $("#inspectionDataTable").mrdForm(formSetting);
            var comType = '${comType}';
            if (!comType || comType != "CC") {
                $("#id4").hide();
                $("#id5").hide();
                $('#id4').attr("disabled", "true");
                $('#id5').attr("disabled", "true");
            }
        });

        function freshGrid() {
            $("#inspectionDataGrid").mrdForm("refreshGrid");
        }
    </script>
</head>
<body>
<div id="inspectionDataTable"></div>
</body>
</html>
